package cn.liontalk.CompositePattern.normal.safe;

import java.util.ArrayList;
import java.util.List;

public class Leader2 extends Employee2 {

    private List<Employee2> employees;


    public Leader2(String name) {
        this.setName(name);
        this.employees = new ArrayList<>();
    }

    public List<Employee2> getEmployees() {
        return employees;
    }

    public void setEmployees(List<Employee2> employees) {
        this.employees = employees;
    }


    public void add(Employee2 employee2){
        this.employees.add(employee2);
    }

    public void remove(Employee2 employee) {
        this.employees.remove(employee);
    }


    @Override
    public void display(int index) {
        for(int i = 0; i < index; i++) {
            System.out.print("----");
        }
        System.out.println("领导：" + this.getName());
        this.employees.forEach(employee -> {
            employee.display(index + 1);
        });
    }
}
